package com.abc.daoimpl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.abc.bean.FdtOaRecorddata;
import com.abc.bean.PageBean;
import com.abc.dao.FdtOaRecorddataDao;
import com.abc.util.HibernateUtil;

public class FdtOaRecorddataImpl implements FdtOaRecorddataDao{
	private Session session;
	private Transaction tx;
	private Query query;
	public void list(PageBean page) {
		try {
			session=HibernateUtil.getSession();
			String hql="from FdtOaRecorddata";
			query=session.createQuery(hql);
			query.setFirstResult((page.getPageNo()-1)*page.getPageSize());
			query.setMaxResults(page.getPageSize());
			page.setList(query.list());
			
			hql="select count(uuid) " +hql;
			query=session.createQuery(hql);
			 int count =((Number)query.uniqueResult()).intValue();
			page.setRowCount(count);
			session.close();
		} catch (Exception e) {
			session.close();
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		 Session session=HibernateUtil.getSession();
		 Query query=session.createQuery("from FdtOaRecorddata");
		 List<FdtOaRecorddata> list = query.list();
		 for (FdtOaRecorddata fdtOaRecorddata : list) {
			System.out.println(fdtOaRecorddata.getMiji());
		}
	}

}
